package com.example.demo.web.controller;

import com.example.demo.bean.DatasetFile;
import com.example.demo.service.IDatasetFileService;
import com.example.demo.utils.Message;
import com.example.demo.utils.MessageUtil;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotNull;
import java.util.List;

@RestController
@RequestMapping("/datasetFile")
public class DatasetFileController {
    @Autowired
    private IDatasetFileService datasetFileService;
    @GetMapping("query")
    public Message query(Long datasetId,String name){
        List<DatasetFile> list=datasetFileService.query( datasetId,name);
        return MessageUtil.success(list);
    }
    @PostMapping("saveOrUpdate")
    public  Message saveOrUpdate(DatasetFile datasetFile){
        datasetFileService.saveOrUpdate(datasetFile);
        return MessageUtil.success("操作成功");
    }
    @DeleteMapping("deleteById")
@ApiImplicitParams({
        @ApiImplicitParam(name="id",value="数据集文件编号",required = true,paramType = "query")
})
    public Message deleteById(@NotNull  Long id){
        datasetFileService.deleteById(id);
        return MessageUtil.success("操作成功");
    }
}
